# copy this file to features/step_definitions subdirectory

# Givens

Given /^I am logged in as "([^\"]*)"$/ do |username|
  user_params = { :login => username, :name => username,
    :password => 'dummy1', :password_confirmation => 'dummy1',
    :email => "#{username}@#{username}.com"}
  @user = User.create!(user_params)
#   controller.stub!(:logged_in?).and_return(true)
#   controller.stub!(:current_user).and_return(@user)
  log_in_user user_params
end

Given /^there is a movie whose (\w+) is "([^\"]*)"$/ do |attrib,value|
  attribs = {:title => "xxxxxxxxx", :description => "xxxxxxxxxx", :rating => 'G'}
  attribs[attrib.to_sym] = value
  Movie.create!(attribs)
end

Then /^I should see a menu with choices "([^\"]*)"$/ do |choices|
  response.should have_selector("select") do |select_tag|
    choices.split(',').each do |c|
      select_tag.should have_selector("option", :content => c.to_s)
    end
  end
end

Then /^I should see a button called "([^\"]*)"$/ do |button_name|
  response.should have_selector("input", :type => 'submit', :value => button_name)
end

# We've provided this regex for you...
# BEFORE you go writing a bunch of Regex's, run Cucumber on review_a_movie.feature and
# see which ones are missing! Keep in mind that some step definitions are
# provided for you already when you ran script/generate cucumber.  (You can see
# them by looking in the features/step_definitions directory.)

Then /^I should go to (.+)$/ do |page_name|
  response.url.should == path_to(page_name)
end


